//
//  CalendarHeaderView.m
//  SCXCalendar
//
//  Created by 桑赐相 on 2017/12/13.
//  Copyright © 2017年 桑赐相. All rights reserved.
//

#import "CalendarHeaderView.h"
@interface CalendarHeaderView()

@property (nonatomic,strong) UIButton *nextBtn;
@property (nonatomic,strong) UIButton *upBtn;
@property (nonatomic,strong) UILabel  *titleLabel;

@end
@implementation CalendarHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubView];
    }
    return self;
}

-(void)initSubView{
    self.backgroundColor = RGB(31,112,207);
    self.upBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 10, 50, 25)];
    [self.upBtn setTitle:@"上一月" forState:UIControlStateNormal];
    [self.upBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.upBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.upBtn];
    
    self.nextBtn = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH - 60,10, 50, 25)];
    [self.nextBtn setTitle:@"下一月" forState:UIControlStateNormal];
    [self.nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.nextBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.nextBtn];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(100,10, WIDTH - 200, 25)];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = [UIFont systemFontOfSize:17];
    
    [self addSubview:self.titleLabel];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 46, WIDTH, 1)];
    view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:view];
    
    UIView *weakView = [[UIView alloc]initWithFrame:CGRectMake(0, 47, WIDTH, HEIGHT - 46)];
    weakView.backgroundColor = [UIColor whiteColor];
    [self addSubview:weakView];
    NSArray *array = @[@"日",@"一",@"二",@"三",@"四",@"五",@"六"];
    CGFloat w = WIDTH / 7;
    for(int i=0;i<array.count;i++){
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i*w,0, w, HEIGHT - 46)];
        label.textAlignment = NSTextAlignmentCenter;
        if(i==0||i==6){
            label.textColor = RGB(31,112,207);
        }else{
            label.textColor = [UIColor darkGrayColor];
        }
        
        label.font = [UIFont systemFontOfSize:14];
        label.text = array[i];
        [weakView addSubview:label];
    }
}
-(void)setDate:(NSString *)date{
    _date = date;
    self.titleLabel.text = date;
}

































@end
